package nuc.edu.tlias.mapper;

import nuc.edu.tlias.pojo.Emp;
import nuc.edu.tlias.pojo.EmpQueryParam;
import org.apache.ibatis.annotations.*;

import javax.xml.stream.events.StartDocument;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
import java.util.Objects;

@Mapper
public interface EmpMapper {


    //原市方式
/*    @Select("SELECT count(*) from emp left join dept on emp.dept_id = dept.id;")
    public Long count();


    @Select("SELECT tlias.emp.*,dept.name deptName from emp left join dept on emp.dept_id = dept.id order by emp.entry_date desc limit #{start},#{pageSize};")
    public List<Emp> list (@Param("start") Integer start,@Param("pageSize") Integer pageSize);*/


    //@Select("SELECT tlias.emp.*,dept.name deptName from emp left join dept on emp.dept_id = dept.id order by emp.entry_date desc")
    public List<Emp> list (EmpQueryParam empQueryParam);

    @Select("select * from emp")
    List<Emp> findall();

    @Options(useGeneratedKeys = true,keyProperty = "id")
    @Insert("INSERT  into emp (username, name, gender, phone, job, salary, image, entry_date, dept_id, create_time, update_time) " +
            "values (#{username},#{name},#{gender},#{phone},#{job},#{salary},#{image},#{entryDate},#{deptId},#{createTime},#{updateTime})")
    void insert(Emp emp);


    void deleteByIds(@Param("ids") Integer[] ids);

    Emp findById(Integer id);

    void update(Emp emp);
    @MapKey("pos")
    List<Map<String, Object>> EmpJobData();

    @MapKey("name")
    List<Map<String, Object>> getEmpGenderData();

    @Select("select id,username,name from emp where username = #{username} and password = #{password}")
    Emp login(Emp emp);
}

